import { useCounterStore } from "../stores/user";

function panduan(ifIn) {
	if (ifIn == true) {
		const user = useCounterStore()
		if (!user.userinfo.id) {
			uni.$showMsg('未登录')
			return true
		} else {
			return false
		}
	}
}
export default {
	/**
	 * 跳转tab页面
	 */
	switchTab(url, ifIn = false) {
		if (panduan(ifIn)) return
		uni.switchTab({
			url: url
		});
	},

	/* 跳转某个页面 */
	navigateTo(url, ifIn = false) {
		if (panduan(ifIn)) return
		uni.navigateTo({
			url: url
		});
	},

	/* 关闭当前页面跳到摸个页面 */
	redirectTo(url, ifIn = false) {
		if (panduan(ifIn)) return
		uni.redirectTo({
			url: url
		})
	},
	navigateBack(val = 1) {
		uni.navigateBack(val)
	},

}